package com.zxh.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.zxh.service.TestService;
import org.apache.dubbo.config.annotation.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

@Service
public class TestServiceImpl implements TestService {
    public Map<String, Object> methodA() {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("methodA","hello methodA");
        System.out.println(JSONObject.toJSONString(map));
        sleep();
        return map;
    }

    public Map<String, Object> methodB() {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("methodB","hello methodB");
        System.out.println(JSONObject.toJSONString(map));
        sleep();
        return map;
    }

    public Map<String, Object> methodC() {
        Map<String,Object> map = new HashMap<String, Object>();
        map.put("methodC","hello methodC");
        System.out.println(JSONObject.toJSONString(map));
        sleep();
        return map;
    }

    private void sleep() {
        try {
            Thread.sleep(new Random().nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
